<?php
error_reporting(E_ALL ^ E_NOTICE);
set_time_limit(0);
$db_name="dinocap2";  
 
$table_name="dinocap2hd";  
 
$connection= @mysql_connect("localhost","root","root") or die(mysql_error());  
 
$db= @mysql_select_db($db_name,$connection) or die (mysql_error());  
 
$logdate =  mysql_query("SELECT DISTINCT whatday FROM `dinocap2hd`");
$dateTime = date("Y-m-d",strtotime("-1 day"));


while($everylogdate = mysql_fetch_array($logdate))
{
var_dump($everylogdate[whatday]);
  $deviceid_query = mysql_query("SELECT distinct deviceid  FROM  dinocap2hd  where dayIapMoney >0 and whatday BETWEEN date_sub( '$everylogdate[whatday]', INTERVAL 14
DAY ) AND DATE_SUB( '$everylogdate[whatday]', INTERVAL 7
DAY ) and  isjailbreak = '0'
 ");

  while($deviceid = mysql_fetch_array($deviceid_query)) {

 //var_dump($deviceid);
     mysql_query("INSERT INTO weekPay (deviceid,date) 
                    VALUES('$deviceid[deviceid]','$everylogdate[whatday]')") or die(mysql_error());
}

 
  
}

?>